/*******************************************************************************
 * Copyright (c) 2010, 2018 西安秦晔信息科技有限公司
 * Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 *******************************************************************************/
package com.qinyeit.serviceapp.test.service.branchdatasource;

import com.qinyeit.serviceapp.test.service.BaseApplicationTest;
import com.qinyetech.springstage.core.lang.QyMap;
import com.qinyetech.springstage.core.repository.jdbc.PageNamedParameterJdbcTemplate;
import lombok.extern.slf4j.Slf4j;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * <p>ClassName: com.qinyeit.serviceapp.test.service.branchdatasource.TransactionalTesst
 * <p>Function:  分布式事务测试
 * <p>date: 2018-11-24 11:38
 *
 * @author wuqing
 * @version 1.0
 * @since JDK 1.8
 */
@Slf4j
public class TransactionalTesst extends BaseApplicationTest {


    @Resource(name = "branchJdbcTemplate")
    private PageNamedParameterJdbcTemplate branchJdbcTemplate;

    @Autowired
    private MyEntityService myEntityService;

    @Before
    public void setUp() {
        String createTableScript=
                "CREATE TABLE `jta_tests` (\n" +
                        "  `id` BIGINT(64) NOT NULL AUTO_INCREMENT,\n" +
                        "  `name` VARCHAR(128) DEFAULT NULL,\n" +
                        "  PRIMARY KEY (`id`)\n" +
                        ") ENGINE=INNODB DEFAULT CHARSET=utf8\n";

        branchJdbcTemplate.getJdbcTemplate().execute("DROP TABLE IF EXISTS `jta_tests`");
        branchJdbcTemplate.getJdbcTemplate().execute(createTableScript);
    }
    @After
    public void tearDown() {

    }

    @Test
    public void testSave(){
        myEntityService.testSave();
    }


}
